package anji.plus.system.mark.utils;

import anji.plus.system.mark.base.Header;
import anji.plus.system.mark.domain.SysUser;
import anji.plus.system.mark.exception.BusinessException;
import anji.plus.system.mark.response.ResponseCode;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class LoginUtils {

    @Resource
    RedisUtil redisUtil;

    public SysUser get(String accessToken) {
        if (this.redisUtil.hasKey("loginInfo:" + accessToken)) {
            return (SysUser)this.redisUtil.get("loginInfo:" + accessToken);
        } else {
            throw new BusinessException(ResponseCode.SYSTEM_INVALID_TOKEN);
        }
    }


}
